<template>
    <div class="m_left">
        <div class="left_n">用户中心</div>
        <div class="left_m">
            <div class="left_m_t t_bg1">资讯中心</div>
            <ul>
                <li><a href="#" @click.prevent="toUserNews()">资讯列表</a></li>
            </ul>
        </div>
        <div class="left_m" v-show="valid">
            <div class="left_m_t t_bg2">订单中心</div>
            <ul>
                <li><a href="#" @click.prevent="toUserOrder()">我的订单</a></li>
                <li><a href="#" @click.prevent="toUserAddress()">收货地址</a></li>
            </ul>
        </div>
        <div class="left_m" v-show="valid">
            <div class="left_m_t t_bg1">会员中心</div>
            <ul>
                <li><a href="#" @click.prevent="toUserInfo()">用户信息</a></li>

                <li><a href="#" @click.prevent="toUserCollect()">我的收藏</a></li>
            </ul>
        </div>

        <div class="left_m" v-show="valid">
            <div class="left_m_t t_bg3">账户中心</div>
            <ul>
                <li><a href="#" @click.prevent="$emit('changeView', 'MemberUserUpdateRight')">信息修改</a></li>
                <li><a href="#" @click.prevent="$emit('changeView', 'UpdatePasswordRight')">修改密码</a></li>
            </ul>
        </div>
    </div>
</template>

<script>
export default {
    name: 'UserContentLeft',
    data() {
        return {
            userId: ''
        }
    },
    computed: {
        valid() {
            return this.userId !== ''
        }
    },
    methods: {
        toUserNews() {
            this.$router.push({
                path: '/user',
                query: { tab: 'news' }
            }).catch(() => { });
        },
        toUserInfo() {
            this.$router.push({
                path: '/user',
                query: { tab: 'info' }
            }).catch(() => { });
        }
        , toUserAddress() {
            this.$router.push({
                path: '/user',
                query: {
                    tab: 'address'
                }
            }).catch(() => { });
        }
        , toUserOrder() {
            this.$router.push({
                path: '/user',
                query: {
                    tab: 'order',
                    scope: 'self'
                }
            }).catch(() => { });
        }
        , toUserCollect() {
            this.$router.push({
                path: '/user',
                query: { tab: 'collect' }
            }).catch(() => { });
        }
    },
    mounted() {
        this.userId = window.sessionStorage.getItem('userId') || '';
    }
}
</script>
